import java.util.ArrayList;

public class CutStrategy extends Sale{

    @Override
    public void set_items(ArrayList<SaleItem> items){
        super.set_items(items);
        if(inst_sale != null) inst_sale.set_items(items);
    }
    @Override
    public java.util.ArrayList<SaleItem> get_items() {
        // 若自己没存，向内层要（双保险）
        java.util.ArrayList<SaleItem> mine = super.get_items();
        if ((mine == null || mine.isEmpty()) && inst_sale != null) {
            return inst_sale.get_items();
        }
        return mine;
    }
    protected Sale inst_sale;

    public CutStrategy(Sale sale){
        inst_sale = sale;
    }
    public CutStrategy(){
        inst_sale = null;
    }
    @Override
    public double totalCost() {
        if(inst_sale == null) return 0d;
        return inst_sale.totalCost();  // nodiscount 算没打折前的价格
    }

}
